﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tesla.Graphics;

namespace Tesla.Content.Loaders {
    public abstract class BaseDevILLoader : ResourceLoader<Texture> {

        private DevILTranslator m_translator;
        private DevIL.ImageType m_imageType;

        public BaseDevILLoader(String formatExtension, DevIL.ImageType imageType) : base(formatExtension) {
            m_imageType = imageType;
        }

        protected override void OnInitialize() {
            m_translator = new DevILTranslator();
        }

        public override Texture Load(IResource resource, LoaderParameters parameters) {
            ImageLoaderParameters imageParams = parameters as ImageLoaderParameters;
            if(imageParams == null) {
                imageParams = new ImageLoaderParameters();
            }

            return m_translator.Load(resource, m_imageType, imageParams);
        }
    }

    public sealed class TGALoader : BaseDevILLoader {

        public TGALoader() : base(".tga", DevIL.ImageType.Tga) { }

    }

    public sealed class DDS2Loader : BaseDevILLoader {

        public DDS2Loader() : base(".dds", DevIL.ImageType.Dds) { }

    }

    public sealed class JPG2Loader : BaseDevILLoader {

        public JPG2Loader() : base(".jpg", DevIL.ImageType.Jpg) { }

    }
}
